home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #2 / Amiga Plus CD - 1997 - No. 02.iso / system / mui / developer / c / examples / showhide.c < prev    next >
C/C++ Source or Header  |  1978-06-11  |  3KB  |  103 lines

  1. /*
  2. ** The ShowHide demo shows how to hide and show objects.
  3. */
  4.  
  5. #include "demo.h"
  6.  
  7.  
  8. int main(int argc,char *argv[])
  9. {
  10.     APTR app,window,cm1,cm2,cm3,cm4,cm5,bt1,bt2,bt3,bt4,bt5;
  11.  
  12.     init();
  13.  
  14.     app = ApplicationObject,
  15.         MUIA_Application_Title      , "ShowHide",
  16.         MUIA_Application_Version    , "$VER: ShowHide 17.6 (18.08.96)",
  17.         MUIA_Application_Copyright  , "©1992/93, Stefan Stuntz",
  18.         MUIA_Application_Author     , "Stefan Stuntz",
  19.         MUIA_Application_Description, "Show object hiding.",
  20.         MUIA_Application_Base       , "SHOWHIDE",
  21.  
  22.         SubWindow, window = WindowObject,
  23.             MUIA_Window_Title, "Show & Hide",
  24.             MUIA_Window_ID   , MAKE_ID('S','H','H','D'),
  25.  
  26.             WindowContents, HGroup,
  27.  
  28.                 Child, VGroup, GroupFrame,
  29.  
  30.                     Child, HGroup, MUIA_Weight, 0,
  31.                         Child, cm1 = CheckMark(TRUE),
  32.                         Child, cm2 = CheckMark(TRUE),
  33.                         Child, cm3 = CheckMark(TRUE),
  34.                         Child, cm4 = CheckMark(TRUE),
  35.                         Child, cm5 = CheckMark(TRUE),
  36.                         End,
  37.  
  38.                     Child, VGroup,
  39.                         Child, bt1 = SimpleButton("Button 1"),
  40.                         Child, bt2 = SimpleButton("Button 2"),
  41.                         Child, bt3 = SimpleButton("Button 3"),
  42.                         Child, bt4 = SimpleButton("Button 4"),
  43.                         Child, bt5 = SimpleButton("Button 5"),
  44.                         Child, VSpace(0),
  45.                         End,
  46.  
  47.                     End,
  48.                 End,
  49.             End,
  50.         End;
  51.  
  52.     if (!app)
  53.         fail(app,"Failed to create Application.");
  54.  
  55.  
  56. /*
  57. ** Install notification events...
  58. */
  59.  
  60.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  61.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  62.  
  63.     DoMethod(cm1,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,bt1,3,MUIM_Set,MUIA_ShowMe,MUIV_TriggerValue);
  64.     DoMethod(cm2,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,bt2,3,MUIM_Set,MUIA_ShowMe,MUIV_TriggerValue);
  65.     DoMethod(cm3,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,bt3,3,MUIM_Set,MUIA_ShowMe,MUIV_TriggerValue);
  66.     DoMethod(cm4,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,bt4,3,MUIM_Set,MUIA_ShowMe,MUIV_TriggerValue);
  67.     DoMethod(cm5,MUIM_Notify,MUIA_Selected,MUIV_EveryTime,bt5,3,MUIM_Set,MUIA_ShowMe,MUIV_TriggerValue);
  68.  
  69.     set(cm3,MUIA_Selected,FALSE);
  70.  
  71. /*
  72. ** This is the ideal input loop for an object oriented MUI application.
  73. ** Everything is encapsulated in classes, no return ids need to be used,
  74. ** we just check if the program shall terminate.
  75. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  76. ** from Wait() (or 0). This makes the input loop significantly faster.
  77. */
  78.  
  79.     set(window,MUIA_Window_Open,TRUE);
  80.  
  81.     {
  82.         ULONG sigs = 0;
  83.  
  84.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  85.         {
  86.             if (sigs)
  87.             {
  88.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  89.                 if (sigs & SIGBREAKF_CTRL_C) break;
  90.             }
  91.         }
  92.     }
  93.  
  94.     set(window,MUIA_Window_Open,FALSE);
  95.  
  96.  
  97. /*
  98. ** Shut down...
  99. */
  100.  
  101.     fail(app,NULL);
  102. }
  103.